﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WaveMaster.Holidays.Club.SQL
{
    public class AutoNumberSQL
    {
        public static string GetLatestNumberByAgentAndType()
        {
            return @"SELECT lastnumber FROM autonumber where m_travelAgentId = ?m_travelAgentId and type=?type";
        }

        public static string GetLatestNumberByAgentAndTypeAndTrip()
        {
            return @"SELECT lastnumber FROM autonumber where m_travelAgentId = ?m_travelAgentId and type=?type  and m_tripID = ?m_tripID";
        }

        public static string InsertAutoNumber()
        {
            return @"INSERT INTO autonumber
           (m_travelAgentId
           ,type
            ,lastnumber
            ,m_tripID
            )
     VALUES
           (?m_travelAgentId
           ,?type, 0
            ,?m_tripID)";
        }
        public static string UpdateLatestAutoNumber()
        {
            string sql = @"UPDATE autonumber
   SET lastnumber=lastnumber+1         
 WHERE  m_travelAgentId = ?m_travelAgentId and type=?type";
            return sql;
        }
        public static string UpdateLatestAutoNumberTrip()
        {
            string sql = @"UPDATE autonumber
   SET lastnumber=lastnumber+1         
 WHERE  m_travelAgentId = ?m_travelAgentId and type=?type and m_tripID = ?m_tripID";
            return sql;
        }

        public static string UpdateMinusAutoNumber()
        {
            string sql = @"UPDATE autonumber
   SET lastnumber=lastnumber-1         
 WHERE  m_travelAgentId = ?m_travelAgentId and type=?type";
            return sql;
        }
    }
}
